package com.hirstlogics.boxarrow.command;

import java.util.ArrayList;

import com.hirstlogics.boxarrow.box.Box;
import com.hirstlogics.boxarrow.model.Model;

public class Continuation {
	Model model=null;
	ArrayList<Box> boxStack = new ArrayList<Box>();
	
	public void setModel(Model model) {
		this.model = model;
	}
	
	public Model getModel(){
		return model;
	}
	
	public void pushBox(Box box){
		boxStack.add(box);
	}
	
	public Box popBox(){
		Box theBox=null;
		if (!boxStack.isEmpty()) {
			int lastOne = boxStack.size()-1;
			theBox = boxStack.remove(lastOne);
		}
		return theBox;
	}
	
	
	public void displayInfo() {
		System.out.println("Current State:");
		System.out.println("Working directory: "+System.getProperty("user.dir"));
		if (model==null) System.out.println("No Model");
		else { 
			model.displayInfo(); 
			System.out.println("Box Stack Depth = "+boxStack.size());
			for (int idx=0;idx<boxStack.size();idx++) {
				Box e=boxStack.get(idx);
				System.out.println(e.getName()+"["+e.getId()+"]");
			}
		}
	}
	
	public void clear() {
		boxStack.clear();
		model = null;
	}
	
	

}
